//
//  CaudleCollectionViewCell.m
//  Menu
//
//  Created by dllo on 15/7/4.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "CaudleCollectionViewCell.h"

@implementation CaudleCollectionViewCell

- (void)dealloc
{
    [_caudleImgView release];
    [_caudleLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    self.caudleImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, 90*HEIGHT)];
    self.caudleImgView.backgroundColor = [UIColor whiteColor];
    self.caudleImgView.layer.cornerRadius = 7;
    self.caudleImgView.layer.masksToBounds = YES;
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.caudleImgView];
    [_caudleImgView release];
    
    self.caudleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.caudleImgView.frame.size.height, self.contentView.frame.size.width, 50*HEIGHT)];
    self.caudleLabel.backgroundColor = [UIColor clearColor];
    self.caudleLabel.font = [UIFont systemFontOfSize:15];
    self.caudleLabel.textAlignment = NSTextAlignmentCenter;
    self.caudleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.caudleLabel];
    [_caudleLabel release];
}

-(void)setCaudleModel:(CaudleModel *)caudleModel
{
    if (_caudleModel != caudleModel)
    {
        [_caudleModel release];
        _caudleModel = [caudleModel retain];
    }
    self.caudleLabel.text = caudleModel.name;
    NSString *urlStr = caudleModel.imageFilename;
    NSURL *url = [NSURL URLWithString:urlStr];
    [self.caudleImgView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanwei1.png"]];
}

@end
